package com.桥接模式;

import com.桥接模式.factory.FileServiceEnum;
import com.桥接模式.factory.FileServiceFactory;
import com.桥接模式.factory.FileTypeEnum;
import com.桥接模式.factory.FileTypeFactory;
import com.桥接模式.fileService.ParentServiceInterface;
import com.桥接模式.fileType.ParentInterface;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class FileController {

    @Autowired
    FileTypeFactory fileTypeFactory;

    @Autowired
    FileServiceFactory fileServiceFactory;

    @GetMapping(value = "/userAdd")
    public String userAdd(String fileService,String fileType){
        ParentServiceInterface serviceInterface = fileServiceFactory.gete(FileServiceEnum.valueOf(fileService));
        ParentInterface parentInterface = fileTypeFactory.get(FileTypeEnum.valueOf(fileType));
        serviceInterface.setParentInterface(parentInterface);
        String s = serviceInterface.userAddFile();
        return s;
    }
}
